﻿using System.Data.Entity.ModelConfiguration;

namespace Service.Model.Map
{
    public class GamePlayerMap : EntityTypeConfiguration<GamePlayer>
    {
        public GamePlayerMap()
        {
            ToTable("dbo.GamePlayer");
            HasKey(gp => new{ gp.GameId, gp.PlayerId});

            Property(gp => gp.GameId).HasColumnName("GameId").IsRequired();
            Property(gp => gp.PlayerId).HasColumnName("PlayerId").IsRequired();

            HasRequired(gp => gp.Game).WithMany(g => g.GamePlayers).HasForeignKey(g => g.GameId);
            HasRequired(gp => gp.Player).WithMany(p => p.GamePlayers).HasForeignKey(p => p.PlayerId);
        }
    }
}